/*
 * @Author: Administrator
 * @Date:   2017-01-10 20:39:51
 * @Last Modified by:   Administrator
 * @Last Modified time: 2017-01-15 10:14:58
 */

'use strict';

<!-- 左侧菜单点击后,使其保持激活状态 -->
(function () {
    var pathname = window.location.pathname;
    $("[href='" + pathname + "']").parent().addClass("active");
    $("[href='" + pathname + "']").parents("ul.treeview-menu").parent().addClass("active");
    $("[href='" + pathname + "']").parents("ul.treeview-menu").show();
})();


function sidebar_collapse() {
    if (typeof($("#sidebar_setting").attr('checked')) == 'undefined') {
        $("#sidebar_setting").attr("checked", "checked");
        $("body").addClass("sidebar-collapse");
        // 更新设置 收缩状态为true
        $.ajax({
            url: '/accounts/settings',
            type: 'POST',
            data: {"sidebar_collapse": "true"},
            dataType: 'json',
            success: function (data) {
                console.log(data);
            }
        });
    } else {
        $("#sidebar_setting").removeAttr("checked");
        $("body").removeClass("sidebar-collapse");
        // 更新设置 收缩状态为false
        $.ajax({
            url: '/accounts/settings',
            type: 'POST',
            data: {"sidebar_collapse": "false"},
            dataType: 'json',
            success: function (data) {
                console.log(data);
            }
        });
    }
}